function Hnew=Hdelta( par0, indmat , H ); 
% function Hdelta( pa0, indmat , H ); 
% Tranform the Hessian from csminwel into a Hessian 
% for the model coefficients 
% GP and AJ 2/14/2005 
% Note: indmat must be limited to the parameters 
parbad=modtomin(par0,indmat); 
np=length( par0 ); 
GG=zeros( np ); 
ii=1; 
for ii=1:np 
    if indmat(ii,1) == 1
        bb=indmat(ii,3); 
        aa=indmat(ii,2); 
        gdiv = 0.5*( bb - aa )/ ( ( 1 + parbad(ii)^2 )^(3/2) ); 
    elseif indmat(ii,1) == 2
        bb=indmat(ii,3); 
        gdiv = exp( parbad(ii) -bb ); 
    end
    GG(ii,ii) = gdiv; 
end 
Hnew=GG*H*GG'; 
[ss,vv,dd]=svd( Hnew );
temp = min( diag( vv ) );  
if  temp < 1e-20 
    disp(['Minimum eigenvalues of Hnew is:',num2str(temp)] ); 
    error('Hnew is not positive definite')
end 
